<template>
<span class="op_dir_Product-wrapper">
  <button v-if="btns.autoAuditPay" title="自动审核并付款"
          class="ui primary button tiny"
          @click.stop.prevent="autoAuditPay()">
         {{btns.autoAuditPay}}
        </button>
	<button v-if="btns.setAutoAmount" title="设置自动审核金额"
				class="ui primary button tiny"
				@click.stop.prevent="setAutoAmount()">
			   {{btns.setAutoAmount}}
			  </button>
</span>
</template>
<script type="text/ecmascript-6">
import tool from 'src/util/tool';
import util from '_util/index';
import logic from '_logic';
import in_array from 'in_array';

import btn_group from 'components/common/btn_group';


export default {
    data() {
        return {}
    },
    components: {},
    methods: {
        autoAuditPay() {
            //warehouseEdit
            let _this = this
            logic.list.checkIds(this, (selected_ids) => {
                if (selected_ids && selected_ids.length > 0) {
					util.http.getDataCom(_this, '/index/Withdraw/selAutoMoney', {
					},(rs) => {
						util.showConfirm(_this, () => {
							let param = {
								ids: selected_ids
							};
							util.http.SR(_this, '/index/Withdraw/autoAuditPay', param, '操作完成', (rs) => {
								logic.list.refreshListData(_this);
							});
						},{content:`目前自动审核并付款的上限为${rs.value}元人民币，<br>是否自动审核`});
					})

                } else {
                    util.showMsg(this, 'error', '请选择');
                }
            });
        },
		setAutoAmount() {
            //warehouseEdit
            let _this = this
			util.http.getDataCom(_this, '/index/Withdraw/selAutoMoney', {
			},(rs) => {
				this.$store.state.global.eventVue.$emit('showPopCom', {
					_this: this,
					id: _this.$route.query.product_id,
					data: {
						fn: {
							sure: function() {
								let number = document.getElementById('Withdraw_limit_number').value;
								if(number>0){
									util.http.SR(_this, '/index/Withdraw/setAutoAmount', {money:number}, '设置成功', (rs) => {
										logic.list.refreshListData(_this);
									});
								}else{
									util.showMsg(this, 'error', '请输入正确的数值。');
								}

							}
						},
						html:`
						<div style='text-align:center'>
						<h3>付款金额小于设置金额时可自动审核并直接付款</h3>
						<div class='field inline _myfiled'><label>自动审核金额上限</label>
						<input type='number'
						id='Withdraw_limit_number'
						width='150px'
						min="0"  value='${rs.value}'
						oninput='if(value<0){this.value=0}'></div>
						</div>
						`
					},
					name: 'confirm'
				});
			})
        },
    },
    computed: {
        ctl() {
            return this.$route.query.ctl;
        },
        is_admin() {
            return util.is_admin(this);
        },
    },
    props: ['btns'],
    created() {},
};
</script>
<style rel="stylesheet/less" lang="less">@dir: "header/";</style>
